package cn.fl.spl.controller;

import cmm.comm.facade.framework.api.ISysCtrlCfgApiService;
import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysCtrlCfgDTO;
import cmm.comm.facade.upload.condition.SysUlFilesRecQueryCondition;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.logger.eum.LogExceptionEnum;
import cn.cmm.base.framework.logger.eum.LogOperEnum;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.DateUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.framework.base.constant.WebBaseConstant;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.product.service.ISplUsrRService;
import cn.fl.product.vo.SplUsrRVO;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.spl.service.ISplVisitRecService;
import cn.fl.spl.vo.SplVisitRecDataAnalysisVO;
import cn.fl.spl.vo.SplVisitRecVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysUlFilesRecService;
import cn.fl.system.vo.SysUlFilesRecVO;
import com.alibaba.fastjson.JSONObject;
import fl.constant.facade.framework.constant.BusinessIdConstant;
import fl.spl.facade.framework.constant.DictionaryConstant;
import fl.spl.facade.framework.constant.SplSystemConstant;
import fl.spl.facade.framework.enums.SplInfoFileCfgEnum;
import fl.spl.facade.spl.api.ISplInfoApiService;
import fl.spl.facade.spl.api.ISplPositionInfoApiService;
import fl.spl.facade.spl.api.ISplVisitRecApiService;
import fl.spl.facade.spl.condition.SplInfoQueryCondition;
import fl.spl.facade.spl.condition.SplPositionInfoQC;
import fl.spl.facade.spl.condition.SplUsrRQC;
import fl.spl.facade.spl.condition.SplVisitRecQC;
import fl.spl.facade.spl.dto.SplInfoDTO;
import fl.spl.facade.spl.dto.SplPositionInfoDTO;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description: 供应商拜访记录 控制层
 */
@Controller
@RequestMapping("/spl/splvisitrec")
public class SplVisitRecController extends BaseController {

	/**
	 * SplVisitRec 服务层BEAN
	 */
	@Autowired
	private ISplVisitRecService splVisitRecService;
	/**
	 * PrjBscInfo 服务层BEAN
	 */
	@Autowired
	private IPrjBscInfoService prjBscInfoService;
	/**
	 * 数据字典
	 */
	@Autowired
	private ISysDictionaryApiService sysDictionaryApiService;
	/**
	 * 供应商基础服务
	 */
	@Autowired
	private ISplInfoApiService splInfoApiService;
	/**
	 * 系统配置API
	 */
	@Autowired
	private ISysCtrlCfgApiService sysCtrlCfgApiService;
	/**
	 * SplUsrR 服务层BEAN
	 */
	 @Autowired
	 private ISplUsrRService splUsrRService;
	/**
	 * SysUlFilesRec 服务层BEAN
	 */
	@Autowired
	private ISysUlFilesRecService sysUlFilesRecService;
	/**
	 * 客户 服务层BEAN
	 */
	@Autowired
	private ICstBscInfoService cstBscInfoService;
	/**
	 * 组织架构服务
	 */
	//@Autowired
	//private ISysOrgApiService sysOrgApiService;
	/**
	 * 供应商位置信息 服务层接口
	 */
	@Autowired
	private ISplPositionInfoApiService splPositionInfoApiService;
	@Autowired
	private ISplVisitRecApiService splVisitRecApiService;
	
	/**
	 * 到列表页面
	 */
	@RequestMapping(value = "/toListPage.do", method = { RequestMethod.GET })
	public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {

		ModelAndView view = new ModelAndView("spl/splVisitRec/splVisitRecList");

		String isBisic = request.getParameter("isBisic");

		if(StringUtils.isNotEmpty(isBisic) && BaseConstant.IS_YESNO_YES_STR.equals(isBisic)){
			view = new ModelAndView("spl/splVisitRec/splBisicVisitRecList");
		}

		// 事业部
		List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();

		// 拜访目的数据字典查询
		Map<String, String> purpCdMap = this.sysDictionaryApiService.searchGroupToMap(SplSystemConstant.SPL_SYS_CD,
				SplSystemConstant.DEFAULT_ORG_CD, DictionaryConstant.VISIT_PURP_CD);
		
		// 有拜访记录的事业部集合
		//Map<String, String> buOrgCdMap = this.splVisitRecApiService.searchSplVisitRecBuOrgCdList(null);

		String currentOrgCd = CurrentThreadContext.getCurrentOrgCd();
		if (currentOrgCd.length() > 8) {
			if (CollectionUtils.isNotEmpty(orgList)) {
				for (KeyValueVO kv : orgList) {
					if (kv.getKey().equals(currentOrgCd.substring(0, 8))) {
						view.addObject("currOrg", CurrentThreadContext.getCurrentOrgCd());
						break;
					}
				}
			}
		}

		view.addObject("purpCdMap", purpCdMap);
		//view.addObject("buOrgCdMap", buOrgCdMap);
		view.addObject("buOrgCd", CurrentThreadContext.getCurrentBuOrgCd());

		return view;
	}
	
	/**
	 * 到效能统计列表页面
	 */
	@RequestMapping(value = "/toAnalysisPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAnalysisPage(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView view = new ModelAndView("spl/splVisitRec/splVisitRecAnalysisList");

		return view;
	}
	
	/**
	 * 到单个客户经理的拜访记录列表页面
	 */
	@RequestMapping(value = "/toVisitListByOnePage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toVisitListByOnePage(HttpServletRequest request, HttpServletResponse response) {

		String cstManagerNm = request.getParameter("cstManagerNm");

		ModelAndView view = new ModelAndView("spl/splVisitRec/splVisitRecListByOne");
		
		view.addObject("cstManagerNm", cstManagerNm);

		return view;
	}
	
	/**
	 * 到统计拜访经销商次数页面
	 */
	@RequestMapping(value = "/toVisitSplAnalysisPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toVisitSplAnalysisPage(HttpServletRequest request, HttpServletResponse response) {

		String cstManagerId = request.getParameter("cstManagerId");

		ModelAndView view = new ModelAndView("spl/splVisitRec/splVisitSplAnalysis");
		
		view.addObject("cstManagerId", cstManagerId);

		return view;
	}
	
	/**
	 * 到统计拜访经销商页面
	 */
	@RequestMapping(value = "/toSplAnalysisPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toSplAnalysisPage(HttpServletRequest request, HttpServletResponse response) {

		String cstManagerId = request.getParameter("cstManagerId");
		
		ModelAndView view = new ModelAndView("spl/splVisitRec/splSplAnalysis");
		
		view.addObject("cstManagerId", cstManagerId);
		
		return view;
	}

	/**
	 * 初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initList(HttpServletRequest request, HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String splNm = request.getParameter("splNm");// 供应商名称
		String visitPurpCd = request.getParameter("visitPurpCd");// 拜访目的
		String roleTypCd = request.getParameter("roleTypCd");// 拜访角色类型
		String visitTmStar = request.getParameter("visitTmStar");// 拜访时间上区间
		String visitTmEnd = request.getParameter("visitTmEnd");// 拜访时间下区间
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");// 所属公司
		String crtUsrNm = request.getParameter("crtUsrNm");// 负责人(创建人)
		String rgnPrCd = request.getParameter("rgnProvCd");//省code
		String rgnCyCd = request.getParameter("rgnCityCd");//市code
		String isValid = request.getParameter("isValid");
		String isDel = request.getParameter("isDel");
		String isBisic = request.getParameter("isBisic");//是否关键经销商

		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}

		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}
		// 根据省市查出对应经销商,再根据经销商ID集合查询拜访记录
		List<Long> splIds = null;
		if (StringUtils.isNotEmpty(rgnPrCd) || StringUtils.isNotEmpty(rgnCyCd)) {
			SplInfoQueryCondition splInfoCondition = new SplInfoQueryCondition();
			if (StringUtils.isNotEmpty(rgnCyCd)) {
				splInfoCondition.setRgnCyCd(rgnCyCd);
			}
			if (StringUtils.isNotEmpty(rgnPrCd)) {
				splInfoCondition.setRgnPrCd(rgnPrCd);
			}
			splInfoCondition.setIsDel(9);//查询所有供应商
			List<SplInfoDTO> splInfoList = this.splInfoApiService.searchSplInfoList(splInfoCondition);
			if(CollectionUtils.isNotEmpty(splInfoList)){
				splIds = new ArrayList<>();
				for (SplInfoDTO splInfoDTO : splInfoList) {
					splIds.add(splInfoDTO.getId());
				}
			}
		}

		SplVisitRecQC qc = new SplVisitRecQC();
		if (StringUtils.isNotEmpty(splNm)) {
			qc.setSplNm(splNm);
		}
		if (StringUtils.isNotEmpty(visitPurpCd)) {
			qc.setVisitPurpCd(visitPurpCd);
		}
		if (StringUtils.isNotEmpty(roleTypCd)) {
			qc.setRoleTypCd(Integer.valueOf(roleTypCd));
		}else{
			qc.setRoleTypCd(1);
		}
		if (StringUtils.isNotEmpty(visitTmStar) && StringUtils.isNotEmpty(visitTmEnd)) {
			qc.setVisitTmStar(DateUtils.formatStringToDate(visitTmStar, DateUtils.YYYY_MM_DD));
			Date visitTmEndDate = DateUtils.formatStringToDate(visitTmEnd, DateUtils.YYYY_MM_DD);
			qc.setVisitTmEnd(visitTmEndDate);
		}
		if (StringUtils.isNotEmpty(crtUsrNm)) {
			qc.setCrtUsrNm(crtUsrNm);
		}
		if (StringUtils.isNotEmpty(cstMgrOrgCd) && !cstMgrOrgCd.equals(WebBaseConstant.SYS_P_ORG_CD) && StringUtils.isEmpty(splNm)) {
			qc.setCurOrgCdLike(cstMgrOrgCd);
		}
		if (CollectionUtils.isNotEmpty(splIds)) {
			qc.setSplIds(splIds);
		}
		if (StringUtils.isNotEmpty(isValid) && StringUtils.isNotEmpty(isDel)) {
			qc.setIsDel(Integer.valueOf(isDel));
			qc.setIsValid(Integer.valueOf(isValid));
		}
		if (!CurrentThreadContext.getCurrentBuOrgCd().equals(SplSystemConstant.DEFAULT_ORG_CD)) {
			qc.setBuOrgCd(CurrentThreadContext.getCurrentBuOrgCd());
		}
		page.setCondition(qc);

		Pager pager = new Pager();

		if(StringUtils.isNotEmpty(isBisic) && BaseConstant.IS_YESNO_YES_STR.equals(isBisic)){
			pager = this.splVisitRecService.selectSplBisicVisitListPage(page);
		}else{
			pager = this.splVisitRecService.searchListPage(page);
		}

		List<SplVisitRecVO> list = (List<SplVisitRecVO>) pager.getResultList();

		ListPageVO<SplVisitRecVO> listPage = new ListPageVO<SplVisitRecVO>(list, pager.getTotalCount());
		return listPage;
	}
	
	/**
	 * 初始化效能统计列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initAnalysisList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initAnalysisList(HttpServletRequest request, HttpServletResponse response) {

		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String orgCd = request.getParameter("buOrgCd");// 组织架构
		String visitTmStar = request.getParameter("visitTmStar");// 查询起始时间
		String visitTmEnd = request.getParameter("visitTmEnd");// 查询终止时间
		String cstManagerNm = request.getParameter("cstManagerNm");// 客户经理名称
		
		if (StringUtils.isEmpty(orgCd)) {
			orgCd = CurrentThreadContext.getCurrentOrgCd();
		}

		Pager page = new Pager();
		
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.valueOf(currentPage));
		}
		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.valueOf(pageSize));
		}
		SplVisitRecQC splVisitRecQC = new SplVisitRecQC();
		
		splVisitRecQC.setCurOrgCd(orgCd);
		if (StringUtils.isNotEmpty(visitTmStar) && StringUtils.isNotEmpty(visitTmEnd)) {
			splVisitRecQC.setVisitTmStar(DateUtils.formatStringToDate(visitTmStar, DateUtils.YYYY_MM_DD));
			splVisitRecQC.setVisitTmEnd(DateUtils.formatStringToDate(visitTmEnd, DateUtils.YYYY_MM_DD));
		}
		if (StringUtils.isNotEmpty(cstManagerNm)) {
			splVisitRecQC.setCrtUsrNm(cstManagerNm);
		}
		
		page.setCondition(splVisitRecQC);
		
		Pager resultPager = this.splVisitRecService.searchAnalysisListPage(page);
		List<SplVisitRecDataAnalysisVO> resultList = null;
		Integer total = 0;
		if (null != resultPager) {
			resultList = (List<SplVisitRecDataAnalysisVO>) resultPager.getResultList();
			total = resultPager.getTotalCount();
			
			for (SplVisitRecDataAnalysisVO splVisitRecDataAnalysisVO : resultList) {
				if (null != splVisitRecDataAnalysisVO) {
					if (StringUtils.isEmpty(splVisitRecDataAnalysisVO.getVisitNum())) {
						splVisitRecDataAnalysisVO.setVisitNum(0);
					}
					if (StringUtils.isEmpty(splVisitRecDataAnalysisVO.getVisitCstNum())) {
						splVisitRecDataAnalysisVO.setVisitCstNum(0);
					}
					if (StringUtils.isEmpty(splVisitRecDataAnalysisVO.getCstNums())) {
						splVisitRecDataAnalysisVO.setCstNums(0);
					}
				}
			}
			
			BaseLogUtils.newWebLogger("查询结果==>" + JSONObject.toJSONString(resultList))
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.info();
		}
		
		ListPageVO<SplVisitRecDataAnalysisVO> result = new ListPageVO<SplVisitRecDataAnalysisVO>(resultList, total);
		
		return result;
	}
	
	/**
	 * 统计拜访经销商次数列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initVisitSplNumAnalysisList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initVisitSplNumAnalysisList(HttpServletRequest request, HttpServletResponse response) {

		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String cstManagerId = request.getParameter("cstManagerId");// 客户经理ID
		
		Pager page = new Pager();
		
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.valueOf(currentPage));
		}
		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.valueOf(pageSize));
		}
		SplVisitRecQC splVisitRecQC = new SplVisitRecQC();
		
		if (StringUtils.isNotEmpty(cstManagerId)) {
			splVisitRecQC.setCrtUsrId(Long.valueOf(cstManagerId));
		}
		
		page.setCondition(splVisitRecQC);
		
		Pager resultPager = this.splVisitRecService.searchSplAnalysisForVisitListPage(page);
		List<SplVisitRecDataAnalysisVO> resultList = null;
		Integer total = 0;
		if (null != resultPager) {
			resultList = (List<SplVisitRecDataAnalysisVO>) resultPager.getResultList();
			total = resultPager.getTotalCount();
			BaseLogUtils.newWebLogger("查询结果==>" + JSONObject.toJSONString(resultList))
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.info();
		}
		
		ListPageVO<SplVisitRecDataAnalysisVO> result = new ListPageVO<SplVisitRecDataAnalysisVO>(resultList, total);
		
		return result;
	}
	
	/**
	 * 统计拜访经销商次数列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/initSplNumAnalysisList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initSplNumAnalysisList(HttpServletRequest request, HttpServletResponse response) {

		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String cstManagerId = request.getParameter("cstManagerId");// 客户经理ID
		
		Pager page = new Pager();
		
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.valueOf(currentPage));
		}
		if (StringUtils.isNotEmpty(pageSize)) {
			page.setEveryPage(Integer.valueOf(pageSize));
		}
		SplUsrRQC splUsrRQC = new SplUsrRQC();
		
		if (StringUtils.isNotEmpty(cstManagerId)) {
			splUsrRQC.setUsrId(Long.valueOf(cstManagerId));
		}
		splUsrRQC.setIsPrivate(String.valueOf(BaseConstant.IS_YESNO_YES));
		page.setCondition(splUsrRQC);
		
		Pager resultPager = this.splUsrRService.searchListPage(page);
		List<SplUsrRVO> resultList = null;
		Integer total = 0;
		if (null != resultPager) {
			resultList = (List<SplUsrRVO>) resultPager.getResultList();
			SplPositionInfoQC positionInfoQC = new SplPositionInfoQC();
			List<Long> splIdList = new ArrayList<>();
			for (SplUsrRVO splUsrRVO : resultList) {
				splIdList.add(splUsrRVO.getSplId());
			}
			if(CollectionUtils.isNotEmpty(splIdList)){
				positionInfoQC.setSplIdList(splIdList);
				positionInfoQC.setIsDel(0);
				positionInfoQC.setIsValid(1);
				List<SplPositionInfoDTO> plist = this.splPositionInfoApiService.searchSplPositionInfoList(positionInfoQC);
				for (SplUsrRVO splUsrRVO : resultList) {
					for (SplPositionInfoDTO splPositionInfoDTO : plist) {
						if(splUsrRVO.getSplId().equals(splPositionInfoDTO.getSplId())){
							splUsrRVO.setSplAddr(splPositionInfoDTO.getSplAddr());
						}
					}
				}
			}
			total = resultPager.getTotalCount();
			BaseLogUtils.newWebLogger("查询结果==>" + JSONObject.toJSONString(resultList))
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.info();
		}
		
		ListPageVO<SplUsrRVO> result = new ListPageVO<SplUsrRVO>(resultList, total);
		
		return result;
	}
	
	/**
	 * 组织机构信息
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/searchOrgTree.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object searchOrgTree(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "获取成功");
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");// 客户经理ID

		try {
			JSONArray array = new JSONArray();
			Long currentOrgId = CurrentThreadContext.getCurrentOrgId();
			array = this.prjBscInfoService.searchParentAndCurrentAllsOrgTree(currentOrgId, cstMgrOrgCd);
			// array =
			// this.sysOrgService.searchOrgTreeByCurrentUser(CurrentThreadContext.getCurrentOrgCd(),
			// CurrentThreadContext.getCurrentSysCd());
			if (null == array) {
				array = new JSONArray();
			}
			result.setData(array);
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("获取数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("获取数据失败！");
			BaseLogUtils.newWebLogger("获取数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}
		return result;
	}

	/**
	 * 导出拜访记录
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/exportVisitRec.do", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public Object exportVisitRec(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_BK_EXPORT_SUCC);

		String splNm = request.getParameter("splNm");// 供应商名称
		String visitPurpCd = request.getParameter("visitPurpCd");// 拜访目的
        String roleTypCd = request.getParameter("roleTypCd");// 拜访角色类型
		String visitTmStar = request.getParameter("visitTmStar");// 拜访时间上区间
		String visitTmEnd = request.getParameter("visitTmEnd");// 拜访时间下区间
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");// 所属公司
		String crtUsrNm = request.getParameter("crtUsrNm");// 负责人(创建人)
		String rgnPrCd = request.getParameter("rgnProvCd");//省code
		String rgnCyCd = request.getParameter("rgnCityCd");//市code
		String visitRecTotal = request.getParameter("visitRecTotal");// 拜访记录数量
        String isBisic = request.getParameter("isBisic");//是否关键经销商
		
		SysCtrlCfgDTO ctrlCfgDTO = new SysCtrlCfgDTO();// 查询生效持续时间
		ctrlCfgDTO.setCtrlCode(SplSystemConstant.CTRL_SPL_EXPORT_DATE_NUM);
		ctrlCfgDTO.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);
		ctrlCfgDTO.setSysCd(SplSystemConstant.SPL_SYS_CD);
		SysCtrlCfgDTO entityByPriKey = this.sysCtrlCfgApiService.getEntityByPriKey(ctrlCfgDTO);
		String dateNm = entityByPriKey.getCrtlVal();//拜访记录最多能导出的天数
		
		SplVisitRecQC qc = new SplVisitRecQC();;//拜访记录查询条件

        //时间都为空
        if (StringUtils.isEmpty(visitTmStar) && StringUtils.isEmpty(visitTmEnd)) {
                Date endDate = new Date();
                Date startDate = DateUtils.getDateAddDate(endDate, 5, -Integer.valueOf(dateNm));
                qc.setVisitTmStar(startDate);
                qc.setVisitTmEnd(endDate);
        }
		// 只能导出最多[dateNm]天的拜访记录
		if (StringUtils.isNotEmpty(visitTmStar) && StringUtils.isNotEmpty(visitTmEnd)) {
			Date endDate = DateUtils.formatStringToDate(visitTmEnd, DateUtils.YYYY_MM_DD);
			Date startDate = DateUtils.formatStringToDate(visitTmStar, DateUtils.YYYY_MM_DD);
			long daysBetweenTwoDates = DateUtils.getDaysBetweenTwoDates(startDate, endDate);//日期之差
			if (daysBetweenTwoDates > Long.valueOf(dateNm)) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("最多只能导出"+dateNm+"天的拜访记录");
				return result;
			}
			qc.setVisitTmStar(startDate);
			qc.setVisitTmEnd(endDate);
		}
		if (StringUtils.isNotEmpty(visitTmEnd) && StringUtils.isEmpty(visitTmStar)) {
			Date endDate = DateUtils.formatStringToDate(visitTmEnd, DateUtils.YYYY_MM_DD);
			Date startDate = DateUtils.getDateAddDate(endDate, 5, -Integer.valueOf(dateNm));
			qc.setVisitTmStar(startDate);
			qc.setVisitTmEnd(endDate);
		}
		if (StringUtils.isNotEmpty(visitTmStar) && StringUtils.isEmpty(visitTmEnd)) {
			Date startDate = DateUtils.formatStringToDate(visitTmStar, DateUtils.YYYY_MM_DD);
			Date endDate = DateUtils.getDateAddDate(startDate, 5, Integer.valueOf(dateNm));
			qc.setVisitTmStar(startDate);
			qc.setVisitTmEnd(endDate);
		}

        // 根据省市查出对应经销商,再根据经销商ID集合查询拜访记录
        List<Long> splIds = null;
        if (StringUtils.isNotEmpty(rgnPrCd) || StringUtils.isNotEmpty(rgnCyCd)) {
            SplInfoQueryCondition splInfoCondition = new SplInfoQueryCondition();
            if (StringUtils.isNotEmpty(rgnCyCd)) {
                splInfoCondition.setRgnCyCd(rgnCyCd);
            }
            if (StringUtils.isNotEmpty(rgnPrCd)) {
                splInfoCondition.setRgnPrCd(rgnPrCd);
            }
            splInfoCondition.setIsDel(9);//查询所有供应商
            List<SplInfoDTO> splInfoList = this.splInfoApiService.searchSplInfoList(splInfoCondition);
            if(CollectionUtils.isNotEmpty(splInfoList)){
                splIds = new ArrayList<>();
                for (SplInfoDTO splInfoDTO : splInfoList) {
                    splIds.add(splInfoDTO.getId());
                }
            }
        }

		if (StringUtils.isNotEmpty(splNm)) {
			qc.setSplNm(splNm);
		}
		if (StringUtils.isNotEmpty(visitPurpCd)) {
			qc.setVisitPurpCd(visitPurpCd);
		}
        if (StringUtils.isNotEmpty(roleTypCd)) {
            qc.setRoleTypCd(Integer.valueOf(roleTypCd));
        }else{
            qc.setRoleTypCd(1);
        }
		if (StringUtils.isNotEmpty(crtUsrNm)) {
			qc.setCrtUsrNm(crtUsrNm);
		}
		if (StringUtils.isNotEmpty(cstMgrOrgCd) && StringUtils.isEmpty(splNm)) {
			qc.setCurOrgCdLike(cstMgrOrgCd);
		}
		if (CollectionUtils.isNotEmpty(splIds)) {
			qc.setSplIds(splIds);
		}

		try {
			Pager page = new Pager();
			page.setEveryPage(Integer.valueOf(visitRecTotal));
			page.setCondition(qc);
			String path = this.splVisitRecService.exportVisitRec(page,isBisic);
			if (StringUtils.isNotEmpty(path)) {
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo(SysLogConstant.LOG_BK_EXPORT_SUCC);
				result.setData(path);
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("导出拜访记录数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newWebLogger("导出拜访记录数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		return result;
	}
	
	/**
	 * 导出效能统计
	 */
	@RequestMapping(value = "/exportVisitAnalysis.do", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public Object exportVisitAnalysis(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, SysLogConstant.LOG_BK_EXPORT_SUCC);

		String orgCd = request.getParameter("buOrgCd");// 所属组织架构
		String visitTmStar = request.getParameter("visitTmStar");// 拜访时间上区间
		String visitTmEnd = request.getParameter("visitTmEnd");// 拜访时间下区间
		String crtUsrNm = request.getParameter("cstManagerNm");// 负责人(创建人)
		String visitRecTotal = request.getParameter("visitRecTotal");// 拜访记录数量
		
		
		SplVisitRecQC qc = new SplVisitRecQC();;//拜访记录查询条件
		
		if (StringUtils.isNotEmpty(orgCd)) {
			qc.setCurOrgCd(orgCd);
		}
		if (StringUtils.isNotEmpty(visitTmStar) && StringUtils.isNotEmpty(visitTmEnd)) {
			Date startDate = DateUtils.formatStringToDate(visitTmStar, DateUtils.YYYY_MM_DD);
			Date endDate = DateUtils.formatStringToDate(visitTmEnd, DateUtils.YYYY_MM_DD);
			if (DateUtils.getDaysBetweenTwoDates(startDate, endDate) > 30) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("仅支持导出最多30天的数据,请重新选择时间!");
				return result;
			}
			qc.setVisitTmStar(startDate);
			qc.setVisitTmEnd(endDate);
		} else {
			qc.setVisitTmEnd(new Date());
			qc.setVisitTmStar(DateUtils.getDateAddDate(new Date(), 5, -30));
		}
		if (StringUtils.isNotEmpty(crtUsrNm)) {
			qc.setCrtUsrNm(crtUsrNm);
		}

		try {
			Pager page = new Pager();
			page.setEveryPage(Integer.valueOf(visitRecTotal));
			page.setCondition(qc);
			String path = this.splVisitRecService.exportVisitAnalysis(page);
			if (StringUtils.isNotEmpty(path)) {
				result.setSuccess(BaseConstant.IS_YESNO_YES);
				result.setInfo(SysLogConstant.LOG_BK_EXPORT_SUCC);
				result.setData(path);
			}
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("导出拜访记录数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
			BaseLogUtils.newWebLogger("导出拜访记录数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		return result;
	}

	/**
	 * 查看附件
	 */
	@RequestMapping(value = "/viewAttachments.do", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public Object viewAttachments(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		String id = request.getParameter("id");

		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES);

		SysUlFilesRecQueryCondition condition = new SysUlFilesRecQueryCondition();
		condition.setPkId(id);
		condition.setSysCd(SplSystemConstant.SPL_SYS_CD);
		condition.setCfgCd(SplInfoFileCfgEnum.SPL012.name());
		condition.setOrgCd(SplSystemConstant.DEFAULT_ORG_CD);

		List<SysUlFilesRecVO> searchList = null;
		JSONArray jsonArray = null;
		try {
			searchList = this.sysUlFilesRecService.searchList(condition);

			if (CollectionUtils.isNotEmpty(searchList)) {
				jsonArray = new JSONArray();

				for (SysUlFilesRecVO sysUlFilesRecVO : searchList) {
					jsonArray.add(sysUlFilesRecVO.getFilePath());
				}
			}

		} catch (Exception e) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("查询失败");
			BaseLogUtils.newWebLogger("查询附件失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(e)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}
		result.setData(jsonArray);

		return result;
	}

	/**
	 * 到新增修改页面
	 */
	@RequestMapping(value = "/toAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {

		ModelAndView view = new ModelAndView("spl/splVisitRec/splVisitRecAdd");

		return view;
	}

	/**
	 * 到修改页面
	 */
	@RequestMapping(value = "/toModifyPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toModifyPage(HttpServletRequest request, HttpServletResponse response) {

		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("spl/splVisitRec/splVisitRecModify");
		view.addObject("id", id);
		return view;
	}

	/**
	 * 到详情页面
	 */
	@RequestMapping(value = "/toDetailPage.do", method = { RequestMethod.GET })
	public ModelAndView toDetailPage(HttpServletRequest request, HttpServletResponse response) {

		String id = request.getParameter("id");
		ModelAndView view = new ModelAndView("spl/splVisitRec/splVisitRecDetail");
		view.addObject("id", id);

		return view;
	}

	/**
	 * 新增
	 */
	@RequestMapping(value = "/add.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object add(HttpServletRequest request, HttpServletResponse response) throws BaseException {

		String name = request.getParameter("name");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "新增成功!");
		SplVisitRecVO entity = null;
		try {
			entity = new SplVisitRecVO();
			// TODO ADD PARAM
			Long id = this.splVisitRecService.add(entity);
			result.setData(id);
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("新增对象失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
			BaseLogUtils.newWebLogger("新增对象失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		return result;
	}

	/**
	 * 修改
	 */
	@RequestMapping(value = "/modify.do", method = { RequestMethod.POST })
	@ResponseBody
	public Object modify(HttpServletRequest request, HttpServletResponse response) throws BaseException {

		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "修改成功!");
		if (StringUtils.isEmpty(id)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("数据不存在!");
			BaseLogUtils.newWebLogger("修改对象,主键不存在").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
			return result;
		}
		SplVisitRecVO entity = null;
		try {
			entity = new SplVisitRecVO();
			entity.setId(Long.valueOf(id));
			// entity.setName(name);
			// TODO ADD PARAM
			boolean success = this.splVisitRecService.modify(entity);
			if (!success) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("修改失败!");
				BaseLogUtils.newWebLogger("修改对象失败").setLogOperType(LogOperEnum.RESP)
						.setSysCd(CurrentThreadContext.getCurrentSysCd())
						.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
						.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
						.setWarning(false)
						.warn(LogExceptionEnum.COMMON_CODE_0002);
			}
			BaseLogUtils.newWebLogger("修改成功").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.info();
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("修改对象失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
			BaseLogUtils.newWebLogger("修改对象失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		return result;
	}

	/**
	 * 删除数据
	 */
	@RequestMapping(value = "/removeById.do", method = { RequestMethod.POST })
	@ResponseBody
	public DataResultVO removeById(HttpServletRequest request, HttpServletResponse response) throws BaseException {

		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "删除成功!");
		if (StringUtils.isEmpty(id)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("主键不能为空!");
			return result;
		}
		try {
			this.splVisitRecService.removeById(Long.valueOf(id));
			BaseLogUtils.newWebLogger("删除数据").setLogOperType(LogOperEnum.RESP)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.info();
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("移除对象失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
			BaseLogUtils.newWebLogger("移除对象失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		return result;
	}

	/**
	 * 得到一条记录
	 * 
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getById.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object getById(HttpServletRequest request, HttpServletResponse response) throws BaseException {
		Long startTm = System.currentTimeMillis();

		String id = request.getParameter("id");
		DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "操作成功!");
		if (StringUtils.isEmpty(id)) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("主键不能为空!");
			BaseLogUtils.newWebLogger("获取数据失败,主键不存在").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.warn(LogExceptionEnum.COMMON_CODE_0001);
			return result;
		}

		try {
			SplVisitRecVO vo = this.splVisitRecService.selectById(Long.valueOf(id));
			if (null == vo) {
				result.setSuccess(BaseConstant.IS_YESNO_NO);
				result.setInfo("数据不存在!");
				BaseLogUtils.newWebLogger("获取数据失败,数据不存在").setLogOperType(LogOperEnum.REQ)
						.setSysCd(CurrentThreadContext.getCurrentSysCd())
						.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
						.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
						.setWarning(false)
						.warn(LogExceptionEnum.COMMON_CODE_0002);
			}
			result.setData(vo);
			BaseLogUtils.newWebLogger("获取数据.[id=" + id + "]")
					.setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.info();
		} catch (BaseException ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo(ex.getMessage());
			BaseLogUtils.newWebLogger("获取数据失败,业务异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.warn(LogExceptionEnum.COMMON_CODE_0002);
		} catch (Exception ex) {
			result.setSuccess(BaseConstant.IS_YESNO_NO);
			result.setInfo("系统错误,请联系管理员!");
			BaseLogUtils.newWebLogger("获取数据失败,系统异常").setLogOperType(LogOperEnum.REQ)
					.setSysCd(CurrentThreadContext.getCurrentSysCd())
					.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
					.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
					.setWarning(false)
					.setThrowable(ex)
					.error(LogExceptionEnum.COMMON_CODE_0099);
		}

		Long endTm = System.currentTimeMillis();
		BaseLogUtils.newWebLogger("根据主键获取对象.耗时：" + (endTm - startTm))
				.setLogOperType(LogOperEnum.REQ)
				.setSysCd(CurrentThreadContext.getCurrentSysCd())
				.setChannelCd(SplSystemConstant.FL_WEB_CHL_CD)
				.setBussinessId(BusinessIdConstant.LOG_SPL_MANAGER_CD)
				.setWarning(false)
				.info();
		return result;
	}
	
}
